package org.study.order.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.study.order.feign.StockServiceFeign;
import org.study.order.properties.OrderServiceConfiguration;

import javax.xml.bind.annotation.XmlType;
import java.util.HashMap;
import java.util.Map;

/**
 * @author heshaohua
 * @version 1.0.0
 * @date 2024年07月30日 16:45:00
 */
@Service
public class OrderService {

    private final StockServiceFeign stockServiceFeign;

    private final OrderServiceConfiguration orderServiceConfiguration;

    public OrderService(OrderServiceConfiguration orderServiceConfiguration, StockServiceFeign stockServiceFeign) {
        this.orderServiceConfiguration = orderServiceConfiguration;
        this.stockServiceFeign = stockServiceFeign;
    }


    public Object createOrder(String flag){
        System.out.println(String.format("下单成功:[%s]", flag).toString());
        System.out.println(orderServiceConfiguration.getTimeout());

        Map<String, String> param = new HashMap<>(8);
        param.put("orderId", "xxx");
        return this.stockServiceFeign.deduct(param);
    }
}
